﻿using _03_MVVM_数据绑定_命令绑定.Model;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;

namespace _03_MVVM_数据绑定_命令绑定.ViewModel
{
    class ViewModelMain : ViewModelBase
    {
        /// <summary>
        /// 绑定字符串
        /// </summary>
        private string _bindingText;
        public string BindingText 
        { 
            get => _bindingText; 
            set => Set(ref _bindingText,value);
        }

        /// <summary>
        /// 绑定浮点数
        /// </summary>
        private double _bindingNumber;
        public double BindingNumber
        { 
            get => _bindingNumber; 
            set => Set(ref _bindingNumber, value); 
        }

        /// <summary>
        /// 男/女的枚举类型
        /// </summary>
        private Gender _bindingEnum;
        public Gender BindingEnum 
        { 
            get => _bindingEnum; 
            set => Set(ref _bindingEnum, value); 
        }

        /// <summary>
        /// 显示鼠标的坐标
        /// </summary>
        private string _showingText;
        public string ShowingText 
        { 
            get => _showingText; 
            set => Set(ref _showingText, value); 
        }

        public ViewModelMain()
        {
            InitParams();
        }

        /// <summary>
        /// 初始化参数
        /// </summary>
        private void InitParams()
        {
            BindingText = "测试文本";
            BindingNumber = 2.33;
            BindingEnum = Gender.男;
        }

        /// <summary>
        /// 执行的命令
        /// </summary>
        public RelayCommand<MouseEventArgs> CmdMouseMove => new RelayCommand<MouseEventArgs>(MouseMove);

        //显示鼠标所在的位置
        private void MouseMove(MouseEventArgs e)
        {
            Point point = e.GetPosition(e.Device.Target);
            ShowingText = point.X + "," + point.Y;
        }


    }
}
